package com.yunmang.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.yunmang.R;
import com.yunmang.entity.SavingStatictics;
import com.yunmang.utils.ViewHolderUtils;

import java.util.List;

/**
 * Created by Administrator on 2017/5/22.
 */
public class StaticticsSavingAdapter extends BaseAdapter{
    private List<SavingStatictics.ModelBean> dataList;
    private Context context;
    public StaticticsSavingAdapter(Context context, List<SavingStatictics.ModelBean> dataList){
        this.context=context;
        this.dataList=dataList;
    }
    @Override
    public int getCount() {
        return dataList.size();
    }

    @Override
    public Object getItem(int i) {
        return null;
    }

    @Override
    public long getItemId(int i) {
        return 0;
    }

    @Override
    public View getView(int i, View convertView, ViewGroup viewGroup) {
        SavingStatictics.ModelBean modelBean = dataList.get(i);
        if(convertView==null)
            convertView=View.inflate(context,R.layout.title_saving,null);
        TextView tv_depname = ViewHolderUtils.get(convertView, R.id.tv_depname);
        TextView tv_yunfei = ViewHolderUtils.get(convertView, R.id.tv_yunfei);
        TextView tv_xiafu = ViewHolderUtils.get(convertView, R.id.tv_xiafu);
        TextView tv_daofu = ViewHolderUtils.get(convertView, R.id.tv_daofu);
        TextView tv_collect_money = ViewHolderUtils.get(convertView, R.id.tv_collect_money);
        TextView tv_piaoshu = ViewHolderUtils.get(convertView, R.id.tv_piaoshu);
        tv_depname.setText(modelBean.getDepartName());
        tv_yunfei.setText(modelBean.getTransportCost()+"");
        tv_daofu.setText(modelBean.getTransportCostByConsignee()+"");
        tv_xiafu.setText(modelBean.getTransportCostByShipper()+"");
        tv_collect_money.setText(modelBean.getGoodsCost()+"");
        tv_piaoshu.setText(modelBean.getBillCount()+"");
        return convertView;
    }
    public void refreshData(List<SavingStatictics.ModelBean> dataList){
        this.dataList=dataList;
        notifyDataSetChanged();
    }
}
